<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <script>
    // concat

    // startsWith/endsWith
    const a = "Hello World"
    console.log(a.startsWith("Hello"))

    // includes
    a.includes("llo")

    // indexOf/lastIndexOf
    a.lastIndexOf("o")

    // padStart/padEnd
    console.log("10086".padStart(10, "0"))

    //03:08:12
    const now = new Date()
     // 6
    const min = now.getMinutes()
    console.log((min + "").padStart(2, "0"))  // 6  06  16 16

    // repeat
    const hello = "hello".repeat(10)
    console.log(hello)

    // replace/replaceAll
    //
    const tmd = "qtmd"   // "q***"
    console.log(tmd.replace("tmd", "***"))

    // slice(start, end)   end是负数?
    console.log(a.slice(2))

    // split  1.如果字符串不存在分割号 2.如果分割号是 ""

    // toUpperCase/toLowerCase
    function camelCase(str = "") {   // "xxx" => "Xxx"
      return str.slice(0, 1).toUpperCase() + str.slice(1)
    }

    // camelCase("hello") => Hello
    console.log(camelCase("hello"))

    // trim/trimStart/trimEnd
    a.trim()


    // 实际案例: 统计字符串中字符出现次数  Hello World -> o


  </script>
</body>
</html>
